//
//  UIBarButtonItem+LGBarButtonItem.m
//  微博oc版
//
//  Created by Apple_Lzzy27 on 16/10/10.
//  Copyright © 2016年 Apple_Lzzy27. All rights reserved.
//

#import "UIBarButtonItem+LGBarButtonItem.h"

@implementation UIBarButtonItem (LGBarButtonItem)



- (instancetype)initWithCustButton:(NSString *)title fontSize:(CGFloat)fontSize addTarget:(nullable id)addTarget action:(nonnull SEL)action{
    
    UIButton *butn = [UIButton cz_textButton:title fontSize:fontSize normalColor:[UIColor darkGrayColor] highlightedColor:[UIColor orangeColor]];
    butn.titleLabel.font = [UIFont boldSystemFontOfSize:fontSize];
    [butn addTarget:addTarget action:action forControlEvents:UIControlEventTouchUpInside];
    
   
   return  [self initWithCustomView:butn];
    
}

+ (instancetype)BarButtonCustButton:(NSString *)title fontSize:(CGFloat)fontSize addTarget:(id)addTarget action:(SEL)action isBack:(BOOL)isBack{
    
    UIButton *butn = [UIButton cz_textButton:title fontSize:fontSize normalColor:[UIColor darkGrayColor] highlightedColor:[UIColor orangeColor]];
    butn.titleLabel.font = [UIFont boldSystemFontOfSize:fontSize];
    
    if (isBack) {
        [butn setImage:[UIImage imageNamed:@"navigationbar_back_withtext_highlighted"] forState:UIControlStateHighlighted];
        [butn setImage:[UIImage imageNamed:@"navigationbar_back_withtext"] forState:UIControlStateNormal];
        
        [butn sizeToFit];
    }
    [butn addTarget:addTarget action:action forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:butn];
    return button;
}
@end
